package com.web.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.web.dao.TNewsDao;
import com.web.model.PageBean;
import com.web.model.TNews;
import com.web.service.TNewsService;
import com.web.utils.Pager;

/**
 * 新闻 Service实现
 * 
 * @author wzy
 * 
 */
@Service
public class TNewsServiceImpl implements TNewsService {

	// protected Log log = LogFactory.getLog(getClass());
	@Autowired
	private TNewsDao newsDao;// 注入TNews的dao

	
	public int insert(TNews news) {
		return newsDao.insert(news);
	}

	
	public int deleteByPrimaryKey(Long newId) {
		return newsDao.deleteByPrimaryKey(newId);
	}

	
	public int updateByPrimaryKey(TNews news) {
		return newsDao.updateByPrimaryKey(news);
	}

	
	public TNews selectByPrimaryKey(Long newId) {
		return newsDao.selectByPrimaryKey(newId);
	}

	
	public PageBean<TNews> selectListByPage(Map<String, Object> map) {
		Pager.addPage(map);
		Integer count = newsDao.selectListCount(map);
		List<TNews> list = newsDao.selectList(map);
		PageBean<TNews> pageList = new PageBean<TNews>(list);
		pageList.setTotal(count);
		pageList.setList(list);
		pageList.setPageNum((Integer) map.get("pageNum"));
		pageList.setPageSize((Integer) map.get("pageSize"));
		pageList.setPages(Pager.getPages(count, (Integer) map.get("pageSize")));
		return pageList;
	}

	
	public TNews selectByModelSelective(TNews news) {
		return newsDao.selectByModelSelective(news);
	}
	
	
	public int selectListCount(Map<String, Object> map){
		return newsDao.selectListCount(map);
	}

	
	public List<TNews> selectList(Map<String, Object> map) {
		return newsDao.selectList(map);
	}

	
	public void insertList(List<TNews> list) {
		// TODO Auto-generated method stub
		
	}
}
